/*! ******************************************************************************
 *
 * Created on 2022年3月5日
 *
 * Copyright(c) YuZhou Big Data Laboratory CO.,Ltd, 2022.  All rights reserved.
 *
 *******************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ******************************************************************************/
package org.yzbdl.lanius.ui.spoon.bottom;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.CoolBar;
import org.eclipse.swt.widgets.CoolItem;
import org.eclipse.swt.widgets.ToolBar;

/**
 * @author hs@yzbdl.ac.cn
 *
 */
public class StateButtonGroup extends CoolItem {

    private final String groupName;

    private final ToolBar toolBar;

    public StateButtonGroup(CoolBar parent, String name) {
        this(parent, SWT.NONE, name);
    }

    private StateButtonGroup(CoolBar parent, int style, String name) {
        super(parent, style);

        toolBar = new ToolBar(parent, SWT.NONE);
        RowLayout rowLayout = new RowLayout();
        rowLayout.marginTop = 0;
        rowLayout.marginBottom = 0;
        toolBar.setLayout(rowLayout);
        this.setControl(toolBar);

        this.groupName = name;
    }

    /**
     * @param adapter
     */
    public StateButtonItem addItem(StateButtonItemAdapter adapter) {
        return new StateButtonItem(toolBar, adapter);
    }

    public void setVisible(boolean visible) {
        toolBar.setVisible(visible);
    }

    public ToolBar getToolBar() {
        return toolBar;
    }

    public String getGroupName() {
        return groupName;
    }

    @Override
    protected void checkSubclass() {}

}
